package com.zc.trendsDispatch.controller;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.zc.trendsDispatch.domain.ChargeStationPrediction;
import com.zc.trendsDispatch.service.IChargeStationPredictionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 场站功率预测Controller
 *
 * @author glb
 * @date 2024-02-21
 */
@RestController
@RequestMapping("/trendsDispatch/prediction")
public class ChargeStationPredictionController extends BaseController
{
    @Autowired
    private IChargeStationPredictionService chargeStationPredictionService;

    /**
     * 查询场站功率预测列表
     */
    @PreAuthorize("@ss.hasPermi('trendsDispatch:prediction:list')")
    @GetMapping("/list")
    public TableDataInfo list(ChargeStationPrediction chargeStationPrediction)
    {
        startPage();
        List<ChargeStationPrediction> list = chargeStationPredictionService.selectChargeStationPredictionList(chargeStationPrediction);
        return getDataTable(list);
    }

    /**
     * 导出场站功率预测列表
     */
    @PreAuthorize("@ss.hasPermi('trendsDispatch:prediction:export')")
    @Log(title = "场站功率预测", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ChargeStationPrediction chargeStationPrediction)
    {
        List<ChargeStationPrediction> list = chargeStationPredictionService.selectChargeStationPredictionList(chargeStationPrediction);
        ExcelUtil<ChargeStationPrediction> util = new ExcelUtil<>(ChargeStationPrediction.class);
        util.exportExcel(response, list, "场站功率预测数据");
    }

    /**
     * 获取场站功率预测详细信息
     */
    @PreAuthorize("@ss.hasPermi('trendsDispatch:prediction:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(chargeStationPredictionService.selectChargeStationPredictionById(id));
    }

    /**
     * 获取场站功率预测图表信息
     */
    @PreAuthorize("@ss.hasPermi('trendsDispatch:prediction:getStationInfo')")
    @GetMapping(value = "getStationInfo")
    public AjaxResult getStationInfo(ChargeStationPrediction chargeStationPrediction){
        List<Map> stationInfo = chargeStationPredictionService.getStationInfo(chargeStationPrediction);
        return AjaxResult.success(stationInfo);
    }

    /**
     * 新增场站功率预测
     */
    @PreAuthorize("@ss.hasPermi('trendsDispatch:prediction:add')")
    @Log(title = "场站功率预测", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ChargeStationPrediction chargeStationPrediction)
    {
        return toAjax(chargeStationPredictionService.insertChargeStationPrediction(chargeStationPrediction));
    }

    /**
     * 修改场站功率预测
     */
    @PreAuthorize("@ss.hasPermi('trendsDispatch:prediction:edit')")
    @Log(title = "场站功率预测", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ChargeStationPrediction chargeStationPrediction)
    {
        return toAjax(chargeStationPredictionService.updateChargeStationPrediction(chargeStationPrediction));
    }

    /**
     * 删除场站功率预测
     */
    @PreAuthorize("@ss.hasPermi('trendsDispatch:prediction:remove')")
    @Log(title = "场站功率预测", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(chargeStationPredictionService.deleteChargeStationPredictionByIds(ids));
    }
}
